package com.example.unruly_zhao.mopaide.base;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.unruly_zhao.mopaide.R;
import com.example.unruly_zhao.mopaide.bean.Hotspot_Bean;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Unruly_Zhao on 2017/8/22.
 */

public class News_Adapter extends BaseAdapter {

    private Context mContext;

    private List<Hotspot_Bean.ResultBean.DataBean> hoepost_bean;
    private View mItemView;

    public News_Adapter(Context context, List<Hotspot_Bean.ResultBean.DataBean> hoepost_bean) {
        mContext = context;
        this.hoepost_bean = hoepost_bean;
    }

    @Override
    public int getCount() {
        return 1;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {

        return position;

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder vHolder ;
        if (convertView == null){
            vHolder = new ViewHolder();
            mItemView = LayoutInflater.from(mContext).inflate(R.layout.news_item,parent,false);
            vHolder.tView = (TextView) mItemView.findViewById(R.id.tv_news_wzry);
            vHolder.mImageView = (ImageView) mItemView.findViewById(R.id.img_news_wzry);
            mItemView.setTag(vHolder);

        }else {
            vHolder = (ViewHolder) mItemView.getTag();
        }

        vHolder.tView.setText(hoepost_bean.get(position).getTitle());

        Picasso.with(mContext).load(hoepost_bean.get(position).getThumbnail_pic_s()).into(vHolder.mImageView);


        return mItemView;
    }

    class ViewHolder{
        TextView tView ;

        ImageView mImageView;

    }
}
